package com.lyhengtongwl.zqsnews.widget;

import android.os.CountDownTimer;
import android.widget.TextView;

/**
 * 倒计时
 */
public class CountTimer extends CountDownTimer {

    /**
     * @Fields count : 倒计时
     */
    private static int count = 60 * 1000;
    private static int countDownInterval = 1000;

    private TextView mGetCode;

    public CountTimer(TextView textView) {
        super(count, countDownInterval);
        this.mGetCode = textView;
    }


    public CountTimer(long millisInFuture, long countDownInterval) {
        super(millisInFuture, countDownInterval);
    }

    /**
     * 倒计时过程中调用
     *
     * @param l
     */
    @Override
    public void onTick(long l) {
        mGetCode.setEnabled(false);
        mGetCode.setText(String.valueOf(l / 1000) + "s后重试");
    }

    /**
     * 倒计时完成后调用
     */
    @Override
    public void onFinish() {
        mGetCode.setEnabled(true);
        mGetCode.setText("获取验证码");
    }
}
